package com.common.config;

import com.common.service.WebSocketTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @classDescription:
 * @author:xiayingjie
 * @createTime:16/8/17
 */
//@Configuration
//@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer{

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
        //让其支持sockjs
        webSocketHandlerRegistry.addHandler(webSocketTest(),"/socket");//.withSockJS();
    }

    @Bean
    public WebSocketTest webSocketTest(){
        return new WebSocketTest();
    }
}
